﻿@using Snow.Template.Web.Models.AuditLogs
@model EntityChangeDetailModalViewModel

<table id="EntityPropertyChangesTable" class="table table-bordered">
    <thead>
        <tr>
            <th scope="col">@L("Property")</th>
            <th scope="col">@L("OriginalValue")</th>
            <th scope="col">@L("NewValue")</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var propertyChange in Model.EntityPropertyChanges)
        {
            <tr scope="row">
                <td><strong>@propertyChange.PropertyName</strong></td>
                @if (Type.GetType(propertyChange.PropertyTypeFullName) == typeof(DateTime))
                {
                    <td>@(string.IsNullOrEmpty(propertyChange.OriginalValue) ? "" : DateTimeOffset.Parse(propertyChange.OriginalValue.Replace("\"", "")).ToString("g"))</td>
                    <td>@(string.IsNullOrEmpty(propertyChange.NewValue) ? "" : DateTimeOffset.Parse(propertyChange.NewValue.Replace("\"", "")).ToString("g"))</td>
                    continue;
                }

                <td>@(propertyChange.OriginalValue == "null" ? "" : propertyChange.OriginalValue)</td>
                <td>@(propertyChange.NewValue == "null" ? "" : propertyChange.NewValue)</td>
            </tr>
        }
    </tbody>
</table>
